package com.admin.model;

import java.util.Map;

public class ServiceInstance {
    private String serviceId;
    private String host;
    private int port;
    private boolean secure;
    private Map<String, String> metadata; // 添加元数据字段

    // 添加元数据参数的构造器
    public ServiceInstance(String serviceId, String host, int port, boolean secure, Map<String, String> metadata) {
        this.serviceId = serviceId;
        this.host = host;
        this.port = port;
        this.secure = secure;
        this.metadata = metadata;
    }

    // 省略其他getter和setter

    public Map<String, String> getMetadata() {
        return metadata;
    }

    public String getUri() {
        return (secure ? "https://" : "http://") + host + ":" + port;
    }

    public String getServiceId() {
        return serviceId;
    }

    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public boolean isSecure() {
        return secure;
    }

    public void setSecure(boolean secure) {
        this.secure = secure;
    }

    public void setMetadata(Map<String, String> metadata) {
        this.metadata = metadata;
    }
}

